#ifndef __SERVER_H__
#define __SERVER_H__

#include <sys/socket.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <fcntl.h>
#include <list>

#include "reactor.h"

#define BACKLOG 5

#define CLIENT_PENDING_READ (1<<1) 

struct server
{
  server()
  :sockfd_(0)
  ,port_(0)
  ,threadnum_(2)
  ,io_thread_active_(0)
  ,rt_(nullptr)
  {}


  int sockfd_;
  int port_;
  int threadnum_;
  int io_thread_active_;//是否激活io多线程，默认不激活
  std::list<eventLoop*> client_read_list_;//io线程处理读的全局队列事件
  std::list<eventLoop*> client_write_list_;//i哦现场处理写的全局队列事件
  std::list<int> close_fd_list_;//等待关闭的fd
  reactor* rt_;//reactor
};


extern struct server s;
extern void readQueryFromClient(eventLoop* el);
extern void writeToClient(eventLoop* el);

#endif
